package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.RoomVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
public class NursingLevelController extends BaseController {

    @Autowired
    private NursingLevelService nursingLevelService;

    /**
     * 查询所有护理等级
     */
    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult<List<NursingLevel>> listAll() {
        return success(nursingLevelService.listAll());
    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult addNursingLevel(@RequestBody @ApiParam("护理等级信息") NursingLevelDto nursingLevelDto) {
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return success();
    }

    @GetMapping("/listByPage")
    @ApiOperation("分页查询护理等级")
    public ResponseResult<PageResponse> listByPage(
            @ApiParam(value = "护理等级名称") @RequestParam(required = false) String name,
            @ApiParam(value = "护理等级状态") @RequestParam(required = false) Integer status,
            @ApiParam(value = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页数量") @RequestParam(defaultValue = "10") Integer pageSize) {
        PageResponse pageResponse = nursingLevelService.selectByPage(name, status, pageNum, pageSize);
        return success(pageResponse);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID查询护理等级")
    public ResponseResult<NursingLevelVo> getById(@PathVariable("id") Long id){
        NursingLevelVo nursingLevelVo = nursingLevelService.findById(id);
        return success(nursingLevelVo);
    }

    @PutMapping("/update")
    @ApiOperation("更新护理等级")
    public ResponseResult update(@RequestBody @ApiParam("护理等级信息") NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("根据ID删除护理等级")
    public ResponseResult deleteById(@PathVariable("id") Long id) {
        nursingLevelService.deleteById(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("更新护理等级状态")
    public ResponseResult isEnable(@PathVariable("id") Long id, @PathVariable("status") Integer status){
        nursingLevelService.isEnable(id,status);
        return success();
    }
}